<!--
指令
    ng-app   模块
    ng-controller  控制器：中间件，视图和模型的装饰器

    ng-cloak 解决表达式闪屏
    ng-model
    ng-bind：块级元素上
    ng-click
    ng-value : 表单上-表达式
    ng-show：显示true 与隐藏false

    ng-true-value 选中时候的值
    ng-false-value 取消时候的值

    ng-options 构造下拉列表的options
视图模型 $scope
双向数据绑定

函数使用方法
angular.version      显示版本号
angular.lowercase()  字符串转小写
angular.uppercase()  字符串转大写
angular.copy()       对象或数组的深拷贝
angular.extend()     对象或数组合并
angular.forEach()    遍历数组或对象
angular.fromJson()
angular.toJson()

-->
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="../1.6.9/angular.min.js"></script>
</head>
<body>
<div ng-app="hd" ng-controller="ctrl">
    <form novalidate class="simple-form">
        Name: <input type="text" ng-model="user.name" /><br />
        E-mail: <input type="email" ng-model="user.email" />(输入email格式)<br />
        Gender: <input type="radio" ng-model="user.gender" value="male" />male
        <input type="radio" ng-model="user.gender" value="female" />female<br />
        <button ng-click="reset()">RESET</button>
        <button ng-click="update(user)">SAVE</button>
    </form>
    <pre>form = {{user | json}}</pre>
    <pre>master = {{master | json}}</pre>
</div>
<script>
    var m = angular.module('hd', []);
    m.controller('ctrl', ['$scope', function ($scope) {
        console.log(angular.version);
        console.log(angular.uppercase('houdunWANG'));
        var obj = {
            name: '人',
            school:{
                name: "人实验小学",
                class: 2
            }
        };
        var obj2 = {};
        angular.copy(obj, obj2);//复制obj到obj2中
        obj2.school.name = '网中学';
        console.log(obj);
        console.log(obj2);

        var obj3 = angular.copy(obj);//复制obj到obj3中
        obj3.school.name = '网3中学';
        console.log(obj3);

        $scope.master = {};
        $scope.update = function (user) {
            // Example with 1 argument
            $scope.master = angular.copy(user);
        };
        $scope.reset = function () {
            // Example with 2 arguments
            angular.copy($scope.master, $scope.user);
        };
        $scope.reset();
    }]);
</script>
</body>
</html>